<?php

require_once 'connect.php';

function getAllUsers() {
    $con = getNewDatabaseConnection();

    // execute query
    $sql = "SELECT * FROM foggy.users";
    $result = pg_query($con, $sql);
    if (!$result) {
        die("Error in SQL query: " . pg_last_error());
    }

    // iterate over result set
    // print each row
    echo "<br />";
    while ($row = pg_fetch_array($result)) {
        echo "id: " . $row['id'] . "<br />";
        echo "First Name: " . $row['first_name'] . "<br />";
        echo "Last Name: " . $row['last_name'] . "<br />";
        echo "email: " . $row['email'] . "<br />";
    }

    // free memory
    pg_free_result($result);

    // close connection
    pg_close($con);
}

getAllUsers();

?>
